package com.ruoyi.zhongkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhongkao.domain.ZkExamSite;
import com.ruoyi.zhongkao.service.IZkExamSiteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 考点Controller
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@Api(tags = "中考-考点信息管理")
@RestController
@RequestMapping("/zhongkao/registrationSite")
public class ZkExamSiteController extends BaseController
{
    @Autowired
    private IZkExamSiteService zkExamSiteService;



    /**
     * 查询考点列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:site:list')")
    @GetMapping("/list")
        @ApiOperation("中考考点信息管理 - 分页查询列表")
    public TableDataInfo list(ZkExamSite zkExamSite)
    {
        startPage();
        List<ZkExamSite> list = zkExamSiteService.selectZkExamSiteList(zkExamSite);
        return getDataTable(list);
    }

    @GetMapping("/all")
        @ApiOperation("中考考点信息管理 - 查询所有数据")
    public AjaxResult getAll()
        {return success(zkExamSiteService.selectZkExamSiteAll());}
    /**
     * 导出考点列表
     */
    @PreAuthorize("@ss.hasPermi('zhongkao:site:export')")
    @Log(title = "考点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("中考考点信息管理 - 导出数据")
    public void export(HttpServletResponse response, ZkExamSite zkExamSite)
    {
        List<ZkExamSite> list = zkExamSiteService.selectZkExamSiteList(zkExamSite);
        ExcelUtil<ZkExamSite> util = new ExcelUtil<ZkExamSite>(ZkExamSite.class);
        util.exportExcel(response, list, "考点数据");
    }

    /**
     * 获取考点详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:site:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("中考考点信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zkExamSiteService.selectZkExamSiteById(id));
    }

    @GetMapping(value = "/selectByCode/{code}")
        @ApiOperation("中考考点信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(zkExamSiteService.selectZkExamSiteByCode(code));
    }
    /**
     * 新增考点
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:site:add')")
    @Log(title = "考点", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("中考考点信息管理 - 新增数据")
    public AjaxResult add(@RequestBody ZkExamSite zkExamSite)
    {
        return toAjax(zkExamSiteService.insertZkExamSite(zkExamSite));
    }

    /**
     * 修改考点
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:site:edit')")
    @Log(title = "考点", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("中考考点信息管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZkExamSite zkExamSite)
    {
        return toAjax(zkExamSiteService.updateZkExamSite(zkExamSite));
    }

    /**
     * 删除考点
     */
    @PreAuthorize("@ss.hasPermi('zhongkao:site:remove')")
    @Log(title = "考点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("中考考点信息管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zkExamSiteService.deleteZkExamSiteByIds(ids));
    }
}
